{% extends "base.html" %}

{% block title %}Cuenta del Banco en D&oacute;lares{% endblock %}
{% block head %}Cuenta del Banco en D&oacute;lares{% endblock %}
{% block headTags %}
<script>
$(document).ready(function(){
    $('#button-1').click(function(){
        // display loading image here...
        $('#loadingImg').css("display", "block");
        });
});
</script>
{% endblock %}
{% block content %}
<div id="o5">
    {% if perms.gestion.add_bancodolares %}
        <form method="POST" action="/banco/dolares/listado/1/">{% csrf_token %}
            <table class="formTableABM" align="center" style="border:0">
                <tr>
                    <td class="formfieldleft2"><span style="font-weight:bold;">{{ form.fecha.label_tag }}</span><br />{{ form.fecha }}<br />{{ form.fecha.errors }}</td>
                    <td class="formfieldleft2"><span style="font-weight:bold;">{{ form.fechaAcreditacion.label_tag }}</span><br />{{ form.fechaAcreditacion }}<br />{{ form.fechaAcreditacion.errors }}</td>
                    <td class="formfieldmiddle2"><span style="font-weight:bold;">{{ form.rubro.label_tag }}</span><br />{{ form.rubro }}<br />{{ form.rubro.errors }}</td>
                    <td class="formfieldmiddle2"><span style="font-weight:bold;">{{ form.debe.label_tag }}</span><br />{{ form.debe }}<br />{{ form.debe.errors }}</td>
                    <td class="formfieldmiddle2"><span style="font-weight:bold;">{{ form.haber.label_tag }}</span><br />{{ form.haber }}<br />{{ form.haber.errors }}</td>
                    <td class="formfieldright2"><br /><input id="button-1" type="submit" value="Agregar" /></td>
                </tr>
            </table>
        </form>
        <br />
        <hr class="info">
    {% else %}
        <p>Usted no tiene permiso para agregar</p>
    {% endif %}
    <form method="POST" action="/banco/dolares/listado/2/">{% csrf_token %}
        <p align="right"><a href="javascript:o('o2'); javascript:o('o5'); window.print();">Imprimir</a> - <a href="/banco/dolares/listado/3/">Ver todos</a> - {{ form2.mes.label_tag }} {{ form2.mes }} {{ form2.anio }} <input type="submit" value="Cambiar" />&nbsp;&nbsp;&nbsp;&nbsp;</p>
    </form>
</div>
    {% if mes == '1' %}<h3>Enero {{ anio }}</h3>
    {% elif mes == '2' %}<h3>Febrero {{ anio }}</h3>
    {% elif mes == '3' %}<h3>Marzo {{ anio }}</h3>
    {% elif mes == '4' %}<h3>Abril {{ anio }}</h3>
    {% elif mes == '5' %}<h3>Mayo {{ anio }}</h3>
    {% elif mes == '6' %}<h3>Junio {{ anio }}</h3>
    {% elif mes == '7' %}<h3>Julio {{ anio }}</h3>
    {% elif mes == '8' %}<h3>Agosto {{ anio }}</h3>
    {% elif mes == '9' %}<h3>Setiembre {{ anio }}</h3>
    {% elif mes == '10' %}<h3>Octubre {{ anio }}</h3>
    {% elif mes == '11' %}<h3>Noviembre {{ anio }}</h3>
    {% elif mes == '12' %}<h3>Diciembre {{ anio }}</h3>
    {% else %}
        <h3>Todos los registros</h3>
    {% endif %}

    <div id="loadingImg">
        <img src="{{ STATIC_URL }}images/ajax-loader.gif"/><br><br>
        Recalculando Saldos<br>
        Por favor espere...
    </div>

    <table class=" lista-gastos tablesorter" align="center" id="sorter_clientes" border="0" cellpadding="0" cellspacing="1" style="width:100%;">
        <thead>
            <tr>
                <th>Fecha</th>
                <th>Acreditaci&oacute;n</th>
                <th>Rubro</th>
                <th>Debe</th>
                <th>Haber</th>
                <th>Saldo</th>
                {% if perms.gestion.change_bancodolares %}
                    <th class="acciones" colspan="2"></th>
                {% else %}
                    <th></th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            <tr>
                <td style="width:auto;"></td>
                <td style="width:auto;"></td>
                <td>SALDO MES ANTERIOR</td>
                <td></td>
                <td></td>
                <td style="text-align:left;width:auto;">
                    U$S&nbsp;&nbsp;{{ saldo_anterior|floatformat:"2"|default_if_none:"" }}
                </td>
                <td class="right"></td>
                <td class="right"></td>
            </tr>
            {% for obj in todo %}
                <tr>
                    <td style="width:auto;">{{ obj.fecha|date:"SHORT_DATE_FORMAT"|default_if_none:"" }}</td>
                    <td style="width:auto;">{{ obj.fechaAcreditacion|date:"SHORT_DATE_FORMAT"|default_if_none:"" }}</td>
                    {% if obj.acreditado %}
                        <td>{{ obj.rubro|default_if_none:"" }}</td>
                    {% else %}
                        <td>{{ obj.rubro|default_if_none:"" }} <span style="color:red">Sin acreditar aun</span></td>
                    {% endif %}
                    <td style="text-align:left;width:auto;">
                        {% if obj.debe %}U$S{% endif %}&nbsp;&nbsp;{{ obj.debe|floatformat:"2"|default_if_none:"" }}
                    </td>
                    <td style="text-align:left;width:auto;">
                        {% if obj.haber %}U$S{% endif %}&nbsp;&nbsp;{{ obj.haber|floatformat:"2"|default_if_none:"" }}
                    </td>
                    <td style="text-align:left;width:auto;">
                        U$S&nbsp;&nbsp;{{ obj.saldo|floatformat:"2"|default_if_none:"" }}
                    </td>
                    {% if perms.gestion.change_bancodolares %}
                        <td class="right"><a href="/banco/dolares/editar/{{ obj.id|cut:"." }}/">Editar</a></td>
                        <td class="right"><a href="/banco/dolares/check/{{ obj.id|cut:"." }}/">Eliminar</a></td>
                    {% endif %}
                </tr>
            {% endfor %}
        </tbody>
    </table>
    <br /><br /><br /><br /><br /><br />
{% endblock %}